package com.ytjj.qmyx.mall.enums;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * 
 * @version 1.0
 * 
 */
@Getter
public enum OrderPaySource {
    vip("vip","vip"),
    alipay("alipay","支付宝"),
    wx("wx","微信"),
    union("union","银联");

    private String name;
    private String remark;

    OrderPaySource(String name, String remark) {
        this.name = name;
        this.remark = remark;
    }

    /**
     * 根据支付渠道获取支付来源
     * @param payChannel 支付系统的支付渠道
     * @return String 支付来源
     */
    public static String getPaySource(String payChannel){
        if(StringUtils.isEmpty(payChannel)){
            return "";
        }
        for (OrderPaySource value : OrderPaySource.values()) {
            if(payChannel.startsWith(value.name)){
                return value.name;
            }
        }
        return "";
    }
}
